package com.eos.control.action.report.commission;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.eos.business.service.SysCommissionBusinessService;
import com.eos.common.tool.DataCacheUtil;
import com.eos.control.action.base.AbstractBaseAction;
import com.eos.orm.mybatis.model.SysCustomer;
import com.eos.orm.mybatis.model.ViewBrokerageReport;
import com.hf.utils.PaginationBean;

public class CommissionReportListAction extends AbstractBaseAction {
	private static final long serialVersionUID = 1386946309683554954L;
	private String customerId;
	private String startTime;
	private String endTime;
	private String status;
	private Integer pageNum;
	private Integer numPerPage;
	private Integer totalCount;
	private List<SysCustomer> customerList;
	private List<ViewBrokerageReport> reportList;

	public List<ViewBrokerageReport> getReportList() {
		return reportList;
	}

	public String getCustomerId() {
		return customerId;
	}

	public void setCustomerId(String customerId) {
		this.customerId = customerId;
	}

	public String getStartTime() {
		return startTime;
	}

	public void setStartTime(String startTime) {
		this.startTime = startTime;
	}

	public String getEndTime() {
		return endTime;
	}

	public void setEndTime(String endTime) {
		this.endTime = endTime;
	}

	public Integer getTotalCount() {
		return totalCount;
	}

	public List<SysCustomer> getCustomerList() {
		return customerList;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public Integer getPageNum() {
		return pageNum;
	}

	public void setPageNum(Integer pageNum) {
		this.pageNum = pageNum;
	}

	public Integer getNumPerPage() {
		return numPerPage;
	}

	public void setNumPerPage(Integer numPerPage) {
		this.numPerPage = numPerPage;
	}

	@SuppressWarnings("unchecked")
	@Override
	public String execute() {
		try {
			if(pageNum == null || pageNum.intValue() ==0) pageNum = 1;
			if(numPerPage == null || numPerPage.intValue() ==0) numPerPage = PAGE_SIZE;
			SysCommissionBusinessService scbs = new SysCommissionBusinessService();
			Map<String, String> map = new HashMap<String, String>();
			map.put("cur_page", pageNum+"");
			map.put("page_size", numPerPage+"");
			map.put("table_name", "view_brokerage_report");
			map.put("status", status);
			map.put("customer_id", customerId);
			map.put("start_time", startTime);
			map.put("end_time", endTime);
			PaginationBean pb = scbs.getCommissionReportList(map);
			totalCount = null != pb ? pb.getMaxcount() : 0;
			reportList = null != pb ? (List<ViewBrokerageReport>)pb.getResultList() : null;
			
			List<SysCustomer> suList = DataCacheUtil.getAllSysCustomer();
			if(null != suList){
				List<SysCustomer> nsu = new ArrayList<SysCustomer>();
				for(SysCustomer su : suList){
					if("0".equals(su.getCustomerType())){// 0结算客户;1供应商;2融信
						nsu.add(su);
					}
				}
				customerList = nsu;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return SUCCESS;
	}
}
